package com.my.ph.entity.publish;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.my.ph.entity.media.MediaInfo;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.List;
import java.util.Map;

@Getter
@Accessors(chain = true)
@Builder
@Setter
public class PublishHelperInfo {

    @TableId(type = IdType.AUTO)
    private Long id;
    private String filePath;
    private String mediaType;
    private String mainTitle;
    private String subTitle;
    private String folderName;
    private String intro;
    private String inform;
    private String autoFeedUrl;
    private String source;
    private String host;
    private String torrentPath;
    private String torrentUrl;

    private String torrentName;
    private Integer torrentState;

    private MediaInfo mediaInfo;

    private List<PublishFileInfo> publishFileList;
    private List<Integer> seasons;
    private Map<String, Object> autoFeedMap;

    public PublishHelperInfo() {}

    public PublishHelperInfo(Long id, String filePath, String mediaType, String mainTitle, String subTitle,
                             String folderName, String intro, String inform, String autoFeedUrl, String source,
                             String host, String torrentPath, String torrentUrl, String torrentName, Integer torrentState,
                             MediaInfo mediaInfo, List<PublishFileInfo> publishFileList, List<Integer> seasons, Map<String, Object> autoFeedMap) {
        this.id = id;
        this.filePath = filePath;
        this.mediaType = mediaType;
        this.mainTitle = mainTitle;
        this.subTitle = subTitle;
        this.folderName = folderName;
        this.intro = intro;
        this.inform = inform;
        this.autoFeedUrl = autoFeedUrl;
        this.source = source;
        this.host = host;
        this.torrentPath = torrentPath;
        this.torrentUrl = torrentUrl;
        this.torrentName = torrentName;
        this.torrentState = torrentState;
        this.mediaInfo = mediaInfo;
        this.publishFileList = publishFileList;
        this.seasons = seasons;
        this.autoFeedMap = autoFeedMap;
    }

    public PublishHelperInfo(Long id, String filePath, String mediaType, String mainTitle, String subTitle,
                             String folderName, String intro, String inform, String autoFeedUrl, String source,
                             String host, String torrentPath, String torrentUrl, String torrentName, Integer torrentState,
                             String mediaInfo, String publishFileList, String seasons, String autoFeedMap) {
        this.id = id;
        this.filePath = filePath;
        this.mediaType = mediaType;
        this.mainTitle = mainTitle;
        this.subTitle = subTitle;
        this.folderName = folderName;
        this.intro = intro;
        this.inform = inform;
        this.autoFeedUrl = autoFeedUrl;
        this.source = source;
        this.host = host;
        this.torrentPath = torrentPath;
        this.torrentUrl = torrentUrl;
        this.torrentName = torrentName;
        this.torrentState = torrentState;
        this.mediaInfo = JSONObject.parseObject(mediaInfo, MediaInfo.class);
        this.publishFileList = JSONArray.parseArray(publishFileList, PublishFileInfo.class);
        this.seasons = JSONArray.parseArray(seasons, Integer.class);
        this.autoFeedMap = JSONObject.parseObject(autoFeedMap);
    }

    public String getMediaInfo() {
        return JSONObject.toJSONString(mediaInfo);
    }

    public MediaInfo getMediaInfoObj() {
        return mediaInfo;
    }

    public void setMediaInfo(String mediaInfo) {
        this.mediaInfo = JSONObject.parseObject(mediaInfo, MediaInfo.class);
    }

    public String getPublishFileList() {
        return JSONObject.toJSONString(publishFileList);
    }

    public List<PublishFileInfo> getPublishFileListObj() {
        return publishFileList;
    }

    public void setPublishFileList(String publishFileList) {
        this.publishFileList = JSONArray.parseArray(publishFileList, PublishFileInfo.class);
    }

    public void setPublishFileListObj(List<PublishFileInfo> publishFileList) {
        this.publishFileList = publishFileList;
    }

    public String getSeasons() {
        return JSONObject.toJSONString(seasons);
    }

    public List<Integer> getSeasonsObj() {
        return seasons;
    }

    public void setSeasons(String seasons) {
        this.seasons = JSONArray.parseArray(seasons, Integer.class);
    }

    public String getAutoFeedMap() {
        return JSONObject.toJSONString(autoFeedMap);
    }

    public Map<String, Object> getAutoFeedMapObj() {
        return autoFeedMap;
    }

    public void setAutoFeedMap(String autoFeedMap) {
        this.autoFeedMap = JSONObject.parseObject(autoFeedMap);
    }

    public void setAutoFeedMapObj(Map<String, Object> autoFeedMap) {
        this.autoFeedMap = autoFeedMap;
    }

}
